import * as NS from "../../../Common/NetServices";
import { IsNull } from "../../../TYLibrary/Common/GlobalExtend";
import { Wx_XSPPage } from "../../../Common/Entitys";
import { Log } from "../../../TYLibrary/System/Logger";
import { Wx_PageData, WXDataClassRuntimeDecorator } from "../../../Common/EntityBase";

@WXDataClassRuntimeDecorator()
class AttentionPageData extends Wx_PageData {
    public tabIndex: number = 0;
    public scrollHeight: number = 0;
    public flag: boolean = false;
}


class OrderPage extends Wx_XSPPage {
    private m_index = 0;
    public Data: AttentionPageData = new AttentionPageData();

    /**
     * 初始化页面信息
     * @param {any} options
     * @returns {Promise<void>}
     * @memberof IndexPage
     */
    public async InitData(options: any): Promise<void> {
        wx.getSystemInfo({
            success: res => {
                this.Data.scrollHeight = res.windowHeight;
                this.Data.ApplyChange(this);
            }
        });
        this.Data.tabIndex = 0;
        this.Data.ApplyChange(this);
    }

    /**
     * 滚动切换标签样式
     * @param {*} e
     * @returns {void}
     * @memberof IndexPage
     */
    public switchTabHandler(e: any): void {
        this.m_index = e.detail.current;
        this.Data.tabIndex = e.detail.current;
        this.Data.ApplyChange(this);
    }

    /**
     * 编辑
     * @param {*} e
     * @returns {void}
     * @memberof IndexPage
     */
    public binEditHandler(e: any): void {
        if (this.Data.flag == false) {
            this.Data.flag = true;
            this.Data.ApplyChange(this);
        }
    }

    /**
     * 完成
     * @param {*} e
     * @returns {void}
     * @memberof IndexPage
     */
    public binFinishHandler(e: any): void {
        if (this.Data.flag == true) {
            this.Data.flag = false;
            this.Data.ApplyChange(this);
        }
    }
}

Page(new OrderPage());
